#include "../logs/log.h"
#include <unistd.h>

void testLog(const std::string &name)
{
  INFO("%s", "测试开始");
  mylog::logger::ptr logger = mylog::LoggerManager::GetInstance().getLogger(name);
  logger->debug("%s", "测试日志");
  logger->info("%s", "测试日志");
  logger->warn("%s", "测试日志");
  logger->error("%s", "测试日志");
  logger->fatal("%s", "测试日志");
  INFO("%s", "测试结束");
}
int main()
{  
   std::unique_ptr<mylog::LoggerBuilder> builder(new mylog::GlobalLoggerBuilder());
   builder->BuildLoggerName("sync_logger");
   builder->BuildLoggerType(mylog::LoggerType::Sync_logger);  //采用同步日志器
   //builder->BuildLooperNotSafe();
   builder->BuildFormatter("[%c][%f:%l][%p]%T%m%n");
   builder->BuildLoggerLevel(mylog::LogLevel::value::DEBUG);
   builder->BuildSink<mylog::FileSink>("./logfile/async.log");
   builder->BuildSink<mylog::StdoutSink>();
   builder->BuildSink<mylog::RollFileSink>("./logfile/roll-async-by-size.log/", 1024 * 1024);
   builder->build();
   mylog::logger::ptr logger = mylog::LoggerManager::GetInstance().getLogger("sync_logger");
   testLog("sync_logger");
   
  return 0;
}
